package com.yj.lottery_system.service.mq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

import static com.yj.lottery_system.common.config.DirectRabbitConfig.*;
@Slf4j
@RabbitListener(queues = DLX_QUEUE_NAME)
@Component
public class DlxReceiver {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @RabbitHandler
    public void process(Map<String,String> message) {
        log.info("开始处理异常消息");
        //消息重发
        rabbitTemplate.convertAndSend(EXCHANGE_NAME,ROUTING,message);

    }
}
